/*******************************************************************************
 * Package: com.hngtrust.iir.company.service.impl
 * Type:    CompServiceImpl
 * Date:    2021-5-25 10:29
 *
 * Copyright (c) 2021 HUANENG GUICHENG TRUST CORP.,LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.hngtrust.iir.company.service.impl;

import com.hngtrust.framework.id.service.MyIdGenerator;
import com.hngtrust.framework.page.PageResult;
import com.hngtrust.framework.page.service.PageService;
import com.hngtrust.framework.security.util.SecurityUtils;
import com.hngtrust.iir.base.entity.Dict;
import com.hngtrust.iir.base.entity.Industry;
import com.hngtrust.iir.base.service.DictService;
import com.hngtrust.iir.base.service.IndustryService;
import com.hngtrust.iir.company.controller.vo.AiCompanyReqVO;
import com.hngtrust.iir.company.controller.vo.CompChangeRespVO;
import com.hngtrust.iir.company.controller.vo.ListAssetDebtReqVO;
import com.hngtrust.iir.company.controller.vo.ListAssetDebtRespVO;
import com.hngtrust.iir.company.controller.vo.ListChangeRespVO;
import com.hngtrust.iir.company.controller.vo.ListCompanyReqVO;
import com.hngtrust.iir.company.controller.vo.ListCompanyRespVO;
import com.hngtrust.iir.company.controller.vo.ListDealingRespVO;
import com.hngtrust.iir.company.controller.vo.ListHolderReqVO;
import com.hngtrust.iir.company.controller.vo.ListHolderRespVO;
import com.hngtrust.iir.company.controller.vo.ListInvestRespVO;
import com.hngtrust.iir.company.controller.vo.ListManagementRespVO;
import com.hngtrust.iir.company.controller.vo.ListOperationRespVO;
import com.hngtrust.iir.company.controller.vo.ListPortraitRespVO;
import com.hngtrust.iir.company.controller.vo.ListProfitRespVO;
import com.hngtrust.iir.company.controller.vo.ListTagRespVO;
import com.hngtrust.iir.company.controller.vo.ViewCompanyReqVO;
import com.hngtrust.iir.company.controller.vo.ViewCompanyRespVO;
import com.hngtrust.iir.company.dto.ListChangeReqDTO;
import com.hngtrust.iir.company.dto.ListSubsidiaryDTO;
import com.hngtrust.iir.company.entity.CompChange;
import com.hngtrust.iir.company.entity.CompChangeEntity;
import com.hngtrust.iir.company.entity.CompFinanceGrade;
import com.hngtrust.iir.company.entity.CompHolder;
import com.hngtrust.iir.company.entity.CompInvest;
import com.hngtrust.iir.company.entity.CompManagement;
import com.hngtrust.iir.company.entity.CompPortrait;
import com.hngtrust.iir.company.entity.CompSubsidiary;
import com.hngtrust.iir.company.entity.CompTag;
import com.hngtrust.iir.company.entity.Company;
import com.hngtrust.iir.company.service.CompAssetDebtService;
import com.hngtrust.iir.company.service.CompChangeService;
import com.hngtrust.iir.company.service.CompFinanceGradeService;
import com.hngtrust.iir.company.service.CompHolderService;
import com.hngtrust.iir.company.service.CompInvestService;
import com.hngtrust.iir.company.service.CompManagementService;
import com.hngtrust.iir.company.service.CompPortraitService;
import com.hngtrust.iir.company.service.CompProfitService;
import com.hngtrust.iir.company.service.CompService;
import com.hngtrust.iir.company.service.CompSubsidiaryService;
import com.hngtrust.iir.company.service.CompTagService;
import com.hngtrust.iir.company.service.CompanyService;
import com.hngtrust.iir.company.service.FinanceService;
import com.hngtrust.iir.constant.Constant;
import com.hngtrust.iir.dto.ReqDTO;
import com.hngtrust.iir.exception.IirErrorType;
import com.hngtrust.iir.exception.IirException;
import com.hngtrust.iir.risk.entity.RiskMonitor;
import com.hngtrust.iir.risk.service.RiskMonitorService;
import com.hngtrust.iir.user.entity.Collect;
import com.hngtrust.iir.user.entity.TagRel;
import com.hngtrust.iir.user.entity.User;
import com.hngtrust.iir.user.entity.ViewHistory;
import com.hngtrust.iir.user.service.CollectService;
import com.hngtrust.iir.user.service.TagRelService;
import com.hngtrust.iir.user.service.ViewHistoryService;
import com.hngtrust.iir.util.ListUtil;
import com.hngtrust.pms.business.entity.AsFinanceCont;
import com.hngtrust.pms.business.service.AsFinanceContService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 公司(Company)服务接口
 * @author Chentianyong
 * @date 2021-5-25 10:29
 */
@Slf4j
@Service
public class CompServiceImpl implements CompService {
    
    @Autowired
    private CompanyService companyService;
    
    @Autowired
    private CompHolderService compHolderService;
    
    @Autowired
    private CompManagementService compManagementService;
    
    @Autowired
    private CompChangeService compChangeService;
    
    @Autowired
    private ViewHistoryService viewHistoryService;
    
    @Autowired
    private CompInvestService compInvestService;
    
    @Autowired
    private CompSubsidiaryService compSubsidiaryService;
    
    @Autowired
    private CompPortraitService compPortraitService;
    
    @Autowired
    private CompTagService compTagService;
    
    @Autowired
    private IndustryService industryService;
    
    @Autowired
    private CompProfitService compProfitService;
    
    @Autowired
    private FinanceService financeService;
    
    @Autowired
    private CompAssetDebtService compAssetDebtService;
    
    @Autowired
    private CompFinanceGradeService compFinanceGradeService;
    
    @Autowired
    private AsFinanceContService asFinanceContService;
    
    @Autowired
    private CollectService collectService;
    
    @Autowired
    private TagRelService tagRelService;
    
    @Autowired
    private RiskMonitorService riskMonitorService;
    
    @Autowired
    private DictService dictService;
    
    /**
     * 分页服务
     */
    @Autowired
    private PageService pageService;
    
    /**
     * 主键生成器
     */
    @Autowired
    private MyIdGenerator myIdGenerator;
    
    
    @Value("${tiger.minio.out.address}")
    private String minioAddress;
    
    @Override
    public PageResult<ListCompanyRespVO> queryComp(ReqDTO<ListCompanyReqVO> req) {
        Company company = new Company();
        BeanUtils.copyProperties(req.getContent(), company);
        PageResult<Company> page = pageService.page(req.getPageParam(), () -> companyService.queryComp(company));
    
        PageResult<ListCompanyRespVO> pageResult = new PageResult<>();
        ListUtil<ListCompanyRespVO> listUtil = BeanUtils.instantiateClass(ListUtil.class);
        listUtil.copyList(page,pageResult, ListCompanyRespVO.class);
    
        //数据字典处理
        List<ListCompanyRespVO> voList = new ArrayList<>();
        Map<String, Dict> dictMap = dictService.queryDict("MANAGE_STATE");
        for(ListCompanyRespVO obj:pageResult.getRows()){
            if(null != obj.getManageState() && null != dictMap && null != dictMap.get(obj.getManageState().toString())){
                obj.setManageStateName(dictMap.get(obj.getManageState().toString()).getBusiName());
            }
            
            //logo地址
            if(null != obj.getLogo() && !obj.getLogo().isEmpty()){
                obj.setLogo(minioAddress + obj.getLogo());
            }
            voList.add(obj);
        }
        pageResult.setRows(voList);
        return pageResult;
    }
    
    @Override
    public ViewCompanyRespVO viewCompany(ViewCompanyReqVO req) {
    
        Company company = companyService.queryById(req.getId());
        if(null == company){
            return null;
        }
        ViewCompanyRespVO resp = new ViewCompanyRespVO();
        BeanUtils.copyProperties(company,resp);
    
        //插入查看历史表
        User loginUser = (User) SecurityUtils.getLoginUser().getAdditionalInfo();
        Long userId = loginUser.getId();
        ViewHistory view = new ViewHistory();
        view.setUserId(userId);
        view.setCompId(req.getId());
        view.setId(myIdGenerator.nextId());
        view.setCreateTime(new Date());
        view.setCreateUserId(userId);
        viewHistoryService.add(view);
    
        //组装数据
        //曾用名
        CompChange change = new CompChange();
        change.setCompId(req.getId());
        change.setChangeItem(Constant.COMP_CHANGE_NAME);
        change.setStatus(Constant.DEFAULT_STATUS_NORMAL);
        List<CompChange> changeList = compChangeService.queryList(change);
        String oldName = null;
        for(CompChange obj:changeList){
            if(null != obj.getChangeBefor() && !obj.getChangeBefor().isEmpty()){
                if(null ==  oldName || oldName.isEmpty()) oldName = obj.getChangeBefor();
                else oldName = oldName.concat("," + obj.getChangeBefor());
            }
        }
        resp.setOldName(oldName);
    
        //行业名
        if(null != resp.getIndustry() && resp.getIndustry() > 0L){
            Industry indu = industryService.queryIndustry(resp.getIndustry());
            if(null != indu){
                resp.setIndustryName(indu.getName());
            }
        }
    
        //经营状态名称
        Map<String, Dict> dictInfo = dictService.queryDict("MANAGE_STATE");
        //log.info("getManageState=="+resp.getManageState()+",dictInfo="+dictInfo.toString());
        if(null != resp.getManageState() && null != dictInfo && null != dictInfo.get(resp.getManageState().toString())){
            resp.setManageStateName(dictInfo.get(resp.getManageState().toString()).getBusiName());
        }
    
        //企业性质名称
        if(null != resp.getCompProperty() && resp.getCompProperty() > 0){
            Map<String, Dict> dictMap = dictService.queryDict("COMP_PROPERTY");
            if(null != dictMap && null != dictMap.get(resp.getCompProperty().toString())){
                resp.setCompPropertyName(dictMap.get(resp.getCompProperty().toString()).getBusiName());
            }
        }
    
        //公司类别名称
        if(null != resp.getCompType() && resp.getCompType() > 0){
            Map<String, Dict> dictMap = dictService.queryDict("COMP_TYPE");
            if(null != dictMap && null != dictMap.get(resp.getCompType().toString())){
                resp.setCompTypeName(dictMap.get(resp.getCompType().toString()).getBusiName());
            }
        }
    
        //是否已收藏
        Collect collect = new Collect();
        collect.setCompId(req.getId());
        collect.setCreateUserId(loginUser.getId());
        List<Collect> collectList = collectService.queryList(collect);
        if(!collectList.isEmpty()){
            resp.setCollect(Constant.WHETHER_YES);
        }
        else{
            resp.setCollect(Constant.WHETHER_NO);
        }
    
        //是否已监控
        RiskMonitor riskMonitor = new RiskMonitor();
        riskMonitor.setCompId(req.getId());
        riskMonitor.setCreateUserId(loginUser.getId());
        riskMonitor.setStatus(Constant.DEFAULT_STATUS_NORMAL);
        List<RiskMonitor> riskMonitorList = riskMonitorService.queryList(riskMonitor);
        if(!riskMonitorList.isEmpty()){
            resp.setMonitor(Constant.WHETHER_YES);
        }
        else{
            resp.setMonitor(Constant.WHETHER_NO);
        }
    
        //logo地址
        if(null != resp.getLogo() && !resp.getLogo().isEmpty()){
            resp.setLogo(minioAddress + resp.getLogo());
        }
        
        return resp;
    }
    
    @Override
    public PageResult<ListHolderRespVO> listHolder(ReqDTO<ListHolderReqVO> req) {
        CompHolder compHolder = new CompHolder();
        BeanUtils.copyProperties(req.getContent(),compHolder);
        compHolder.setStatus(Constant.DEFAULT_STATUS_NORMAL);
        ReqDTO<CompHolder> queryReq = new ReqDTO<>();
        queryReq.setPageParam(req.getPageParam());
        queryReq.setContent(compHolder);
        PageResult<CompHolder> page = compHolderService.queryHolder(queryReq);
        //PageResult<CompHolder> page = pageService.page(req.getPageParam(), () -> compHolderService.queryHolder(compHolder));
    
        PageResult<ListHolderRespVO> pageResult = new PageResult<>();
        ListUtil<ListHolderRespVO> listUtil = BeanUtils.instantiateClass(ListUtil.class);
        listUtil.copyList(page,pageResult,ListHolderRespVO.class);
        
        return pageResult;
    }
    
    @Override
    public PageResult<ListManagementRespVO> listManagement(ReqDTO<ListHolderReqVO> req) {
    
        CompManagement compManagement = new CompManagement();
        BeanUtils.copyProperties(req.getContent(),compManagement);
        compManagement.setStatus(Constant.DEFAULT_STATUS_NORMAL);
        PageResult<CompManagement> page = pageService.page(req.getPageParam(), () -> compManagementService.queryManagement(compManagement));
    
        PageResult<ListManagementRespVO> pageResult = new PageResult<>();
        ListUtil<ListManagementRespVO> listUtil = BeanUtils.instantiateClass(ListUtil.class);
        listUtil.copyList(page,pageResult,ListManagementRespVO.class);
    
        //数据字典处理
        List<ListManagementRespVO> voList = new ArrayList<>();
        Map<String, Dict> sexMap = dictService.queryDict("SEX");
        Map<String, Dict> dictMap = dictService.queryDict("MANAGER_TYPE");
        for(ListManagementRespVO obj:pageResult.getRows()){
            if(null != obj.getSex() && null != sexMap && null != sexMap.get(obj.getSex().toString())){
                obj.setSexName(sexMap.get(obj.getSex().toString()).getBusiName());
            }
            if(null != obj.getManagerType() && null != dictMap && null != dictMap.get(obj.getManagerType().toString())){
                obj.setManagerTypeName(dictMap.get(obj.getManagerType().toString()).getBusiName());
            }
            voList.add(obj);
        }
    
        pageResult.setRows(voList);
    
        return pageResult;
    }
    
    @Override
    public PageResult<ListInvestRespVO> listInvest(ReqDTO<ListHolderReqVO> req) {
        CompInvest compInvest = new CompInvest();
        BeanUtils.copyProperties(req.getContent(),compInvest);
        compInvest.setStatus(Constant.DEFAULT_STATUS_NORMAL);
        PageResult<CompInvest> page = pageService.page(req.getPageParam(), () -> compInvestService.queryInvest(compInvest));
    
        PageResult<ListInvestRespVO> pageResult = new PageResult<>();
        ListUtil<ListInvestRespVO> listUtil = BeanUtils.instantiateClass(ListUtil.class);
        listUtil.copyList(page,pageResult,ListInvestRespVO.class);
    
        //营业状态名称
        List<ListInvestRespVO> voList = new ArrayList<>();
        Map<String, Dict> dictMap = dictService.queryDict("MANAGE_STATE");
        if(null != dictMap){
            for(ListInvestRespVO obj:pageResult.getRows()){
                if(null != obj.getBusinessState() && obj.getBusinessState() > 0 && null != dictMap.get(obj.getBusinessState().toString())){
                    obj.setBusinessStateName(dictMap.get(obj.getBusinessState().toString()).getBusiName());
                }
                voList.add(obj);
            }
        }
        pageResult.setRows(voList);
        
        return pageResult;
    }
    
    @Override
    public PageResult<ListSubsidiaryDTO> listSubsidiary(ReqDTO<ListHolderReqVO> req) {
        CompSubsidiary subsidiary = new CompSubsidiary();
        BeanUtils.copyProperties(req.getContent(),subsidiary);
        subsidiary.setStatus(Constant.DEFAULT_STATUS_NORMAL);
        PageResult<ListSubsidiaryDTO> page = pageService.page(req.getPageParam(), () -> compSubsidiaryService.querySubsidiary(subsidiary));
    
        //行业处理
        List<ListSubsidiaryDTO> voList = new ArrayList<>();
        for(ListSubsidiaryDTO obj:page.getRows()){
            if(null != obj.getIndustry() && obj.getIndustry() > 0L){
                Industry indu = industryService.queryIndustry(obj.getIndustry());
                if(null != indu){
                    obj.setIndustryName(indu.getName());
                }
            }
            voList.add(obj);
        }
        page.setRows(voList);
    
        return page;
    }
    
    @Override
    public PageResult<ListChangeRespVO> listChange(ReqDTO<ListChangeReqDTO> req) {
        ListChangeReqDTO changeReq = new ListChangeReqDTO();
        changeReq = req.getContent();
        if(null == changeReq.getCompId() || !(changeReq.getCompId() > 0L)){
            throw new IirException(IirErrorType.INTFACE_PARAMS_ERROR,"compId");
        }
    
        PageResult<CompChange> page = pageService.page(req.getPageParam(), () -> compChangeService.queryChange(req.getContent()));
    
        PageResult<ListChangeRespVO> pageResult = new PageResult<>();
        ListUtil<ListChangeRespVO> listUtil = BeanUtils.instantiateClass(ListUtil.class);
        listUtil.copyList(page,pageResult,ListChangeRespVO.class);
    
        //变更项目类型名称
        List<ListChangeRespVO> voList = new ArrayList<>();
        Map<String, Dict> dictMap = dictService.queryDict("CHANGE_TYPE");
        if(null != dictMap){
            for(ListChangeRespVO obj:pageResult.getRows()){
                if(null != obj.getChangeItem() && obj.getChangeItem() > 0 && null != dictMap.get(obj.getChangeItem().toString())){
                    obj.setChangeItemName(dictMap.get(obj.getChangeItem().toString()).getBusiName());
                }
                voList.add(obj);
            }
        }
        pageResult.setRows(voList);
    
        return pageResult;
    }
    
    @Override
    public List<CompChangeRespVO> compChange(ListHolderReqVO req) {
        CompChange change = new CompChange();
        BeanUtils.copyProperties(req,change);
        change.setStatus(Constant.DEFAULT_STATUS_NORMAL);
        List<CompChangeEntity> list = compChangeService.getChangeCount(change);
    
        Map<String, Dict> dictMap = dictService.queryDict("CHANGE_TYPE");
        List<CompChangeRespVO> resp = new ArrayList<>();
        for(CompChangeEntity obj:list){
            if(null == obj) {
                continue;
            }
            CompChangeRespVO respData = new CompChangeRespVO();
            BeanUtils.copyProperties(obj,respData);
            respData.setCompId(req.getCompId());
            if(null != dictMap && null != obj.getChangeItem() && null != dictMap.get(obj.getChangeItem().toString())){
                respData.setChangeItemName(dictMap.get(obj.getChangeItem().toString()).getBusiName());
                resp.add(respData);
            }
        }
    
        return resp;
    }
    
    @Override
    public List<ListPortraitRespVO> compPortrait(ListHolderReqVO req) {
        CompPortrait portrait = new CompPortrait();
        BeanUtils.copyProperties(req,portrait);
        List<CompPortrait> list = compPortraitService.queryList(portrait);
        List<ListPortraitRespVO> resp = new ArrayList<>();
        ListUtil<ListPortraitRespVO> listUtil = BeanUtils.instantiateClass(ListUtil.class);
        listUtil.copyList(list,resp,ListPortraitRespVO.class);
        
        return resp;
    }
    
    @Override
    public List<ListTagRespVO> compTag(ListHolderReqVO req) {
        CompTag tag = new CompTag();
        BeanUtils.copyProperties(req,tag);
        List<CompTag> list = compTagService.queryList(tag);
    
        List<ListTagRespVO> resp = new ArrayList<>();
        ListUtil<ListTagRespVO> listUtil = BeanUtils.instantiateClass(ListUtil.class);
        listUtil.copyList(list,resp,ListTagRespVO.class);
    
        TagRel tagRel = new TagRel();
        tagRel.setDataId(req.getCompId().toString());
        tagRel.setDataType(Constant.TAG_DATATYPE_COMP);
        List<TagRel> tagRelList = tagRelService.queryList(tagRel);
        for(TagRel obj : tagRelList){
            ListTagRespVO compTag = new ListTagRespVO();
            compTag.setId(obj.getId());
            compTag.setCompId(Long.valueOf(obj.getDataId()));
            compTag.setTagId(obj.getTagId());
            compTag.setTagName(obj.getTagName());
            compTag.setSelfDef(Constant.WHETHER_YES);
            resp.add(compTag);
        }
    
        return resp;
    }
    
    @Override
    public List<ListDealingRespVO> compDealing(ListHolderReqVO req) {
        Company company = companyService.queryById(req.getCompId());
        if(null == company){
            throw new IirException(IirErrorType.INTFACE_PARAMS_ERROR,"ID");
        }
        if(null == company.getSource() || !company.getSource().toUpperCase().equals("PMS")){  //判断如果不是pms来的就返回空
            return new ArrayList<>();
        }
        AsFinanceCont query = new AsFinanceCont();
        query.setDsfbh(company.getSourceId());                   //客户编号
        query.setYwzl(company.getName());
        List<AsFinanceCont> list = this.asFinanceContService.queryDealing(query);
        List<ListDealingRespVO> resp = new ArrayList<>();
    
        Date preHtqdrq = null;
        List<ListDealingRespVO.BusinessData> dataList = new ArrayList<>();
        for(AsFinanceCont obj : list){
            if(null != preHtqdrq && preHtqdrq.compareTo(obj.getHtqdrq()) != 0){
                ListDealingRespVO data = new ListDealingRespVO();
                data.setHtqdrq(preHtqdrq);
                data.setBusinessData(dataList);
                resp.add(data);
                dataList = new ArrayList<>();
            }
            preHtqdrq = obj.getHtqdrq();
            ListDealingRespVO.BusinessData bData = new ListDealingRespVO.BusinessData();
            bData.setHtqdje(obj.getHtqdje());
            bData.setYwzl(obj.getYwzl());
            dataList.add(bData);
        }
        if(null != preHtqdrq){
            ListDealingRespVO data = new ListDealingRespVO();
            data.setHtqdrq(preHtqdrq);
            data.setBusinessData(dataList);
            resp.add(data);
        }
    
        return resp;
    }
    
    @Override
    public List<ListOperationRespVO> compOperation(ListHolderReqVO req) {
        //公司利润表
        ListAssetDebtReqVO compProfit = new ListAssetDebtReqVO();
        compProfit.setType(1);
        compProfit.setCompId(req.getCompId());
        List<ListProfitRespVO> profitList = financeService.listProfit(compProfit);
        if(profitList.isEmpty()){
            return null;
        }
    
        //公司负债表
        List<ListAssetDebtRespVO> assetList = financeService.listAssetDebt(compProfit);
        if(assetList.isEmpty()){
            return null;
        }
    
        //财务综合评分
        CompFinanceGrade compFinanceGrade = new CompFinanceGrade();
        BeanUtils.copyProperties(req,compFinanceGrade);
        compFinanceGrade.setStatus(Constant.DEFAULT_STATUS_NORMAL);
        List<CompFinanceGrade> gradeList = compFinanceGradeService.queryList(compFinanceGrade);
        if(assetList.isEmpty()){
            return null;
        }
    
        //组装数据
        List<ListOperationRespVO> resp = new ArrayList<>();
        Calendar calendar = Calendar.getInstance();
        for(ListProfitRespVO profit:profitList){
            ListOperationRespVO respData = new ListOperationRespVO();
            respData.setCompId(req.getCompId());
            calendar.setTime(profit.getReportPeriod());
            respData.setYear(String.valueOf(calendar.get(Calendar.YEAR)));
            respData.setOperRev(profit.getOperRev());
            respData.setNetProfitInclMinIntInc(profit.getNetProfitInclMinIntInc());
        
            for(ListAssetDebtRespVO asset:assetList){
                if(profit.getReportPeriod().equals(asset.getReportPeriod())){
                    respData.setTotAssets(asset.getTotAssets());
                    respData.setTotNonCurAssets(asset.getTotNonCurAssets());
                    break;
                }
            }
        
            for(CompFinanceGrade grade:gradeList){
                calendar.setTime(profit.getReportPeriod());
                if(grade.getYear().equals(calendar.get(Calendar.YEAR))){
                    respData.setCapitalGrow(grade.getCapitalGrow());
                    respData.setProfitGrow(grade.getProfitGrow());
                    respData.setSalesGrow(grade.getSalesGrow());
                    respData.setTotalAssetGrow(grade.getTotalAssetGrow());
                    break;
                }
            }
            resp.add(respData);
        }
    
        return resp;
    }
    
    @Override
    public List<AiCompanyReqVO> listManagementPost(ListHolderReqVO req) {
        List<CompManagement> list = compManagementService.listType(req.getCompId());
    
        List<AiCompanyReqVO> resp = new ArrayList<>();
        for(CompManagement manage : list){
            AiCompanyReqVO obj = new AiCompanyReqVO();
            obj.setName(manage.getPost());
            resp.add(obj);
        }
    
        return resp;
    }
    
    @Override
    public List<ListCompanyRespVO> queryCompNoPage(ListCompanyReqVO req) {
        Company company = new Company();
        BeanUtils.copyProperties(req, company);
        User loginUser = (User) SecurityUtils.getLoginUser().getAdditionalInfo();
        company.setCreateUserId(loginUser.getId());
        List<Company> page = companyService.queryCompNoPage(company);
    
        List<ListCompanyRespVO> pageResult = new ArrayList<>();
        ListUtil<ListCompanyRespVO> listUtil = BeanUtils.instantiateClass(ListUtil.class);
        listUtil.copyList(page,pageResult, ListCompanyRespVO.class);

        return pageResult;
    }
}
